function Region(params){ 
	 
}

Region.Where = function(type,proxy){
	this.type = type;
	this.proxy=proxy;
	this.linked = null;
	this.set = null;
	if(this.type==0){
		this.set = new Region.Where(1,true);
		this.set.linked = this;
	}
	this.getProxy = function(){
		var m = new Region.Where(this.type);//当前的对像
		if(this.type==0){
			m.set = new Region.Where(1,true);//set对象
			m.set.linked = m;
		}else{
			m.linked=this.linked;
			this.linked.linked=m;
		}
		return m;
	}
	this.data = {};
	this.put = function(key,value){
		this.data[key] = value;
	}
	this.get = function(key){
		return this.data[key];
	}
	/** 编号 [非空]       **/
	this.id=function(id){if(this.proxy)return this.getProxy().id(id);  this.put("id", id);return this;};
	/** and id is null */
	this.idNull=function(){if(this.proxy)return this.getProxy().idNull();if(this.get("idNot")==null)this.put("idNot", "");this.put("id", null);return this;};
	/** not .... */
	this.idNot=function(){if(this.proxy)return this.getProxy().idNot();this.put("idNot", "not");return this;};
	this.idNotNull=function(){if(this.proxy)return this.getProxy().idNotNull();this.put("idNot", "not");this.put("id", null);return this;};
	this.idNot=function(id){if(this.proxy)return this.getProxy().idNot(id);this.put("idNot", "not");this.put("id", id);return this;};
	/** and id <= ? */
	this.idMin=function(min){if(this.proxy)return this.getProxy().idMin(min);this.put("idMin", min);return this;};
	/** and id >= ? */
	this.idMax=function(max){if(this.proxy)return this.getProxy().idMax(max);this.put("idMax", max);return this;};
	this.idIn=function(ids){
		if(this.proxy)return this.getProxy().idIn(ids);  this.put("idIn", ids);return this;
	};	
	
	/** 名称 [非空]       **/
	this.name=function(name){if(this.proxy)return this.getProxy().name(name);  this.put("name", name);return this;};
	/** and name is null */
	this.nameNull=function(){if(this.proxy)return this.getProxy().nameNull();if(this.get("nameNot")==null)this.put("nameNot", "");this.put("name", null);return this;};
	/** not .... */
	this.nameNot=function(){if(this.proxy)return this.getProxy().nameNot();this.put("nameNot", "not");return this;};
	this.nameNotNull=function(){if(this.proxy)return this.getProxy().nameNotNull();this.put("nameNot", "not");this.put("name", null);return this;};
	this.nameNot=function(name){if(this.proxy)return this.getProxy().nameNot(name);this.put("nameNot", "not");this.put("name", name);return this;};
	
	/** 级别    1:省级 2:市级 3:区县级 3:乡镇级     **/
	this.level=function(level){if(this.proxy)return this.getProxy().level(level);  this.put("level", level);return this;};
	/** and level is null */
	this.levelNull=function(){if(this.proxy)return this.getProxy().levelNull();if(this.get("levelNot")==null)this.put("levelNot", "");this.put("level", null);return this;};
	/** not .... */
	this.levelNot=function(){if(this.proxy)return this.getProxy().levelNot();this.put("levelNot", "not");return this;};
	this.levelNotNull=function(){if(this.proxy)return this.getProxy().levelNotNull();this.put("levelNot", "not");this.put("level", null);return this;};
	this.levelNot=function(level){if(this.proxy)return this.getProxy().levelNot(level);this.put("levelNot", "not");this.put("level", level);return this;};
	this.levelIn=function(ids){
		if(this.proxy)return this.getProxy().levelIn(ids);  this.put("levelIn", ids);return this;
	};	
	
	/** 父级  [Region]      **/
	this.parent=function(parent){if(this.proxy)return this.getProxy().parent(parent);  this.put("parent", parent);return this;};
	/** and parent is null */
	this.parentNull=function(){if(this.proxy)return this.getProxy().parentNull();if(this.get("parentNot")==null)this.put("parentNot", "");this.put("parent", null);return this;};
	/** not .... */
	this.parentNot=function(){if(this.proxy)return this.getProxy().parentNot();this.put("parentNot", "not");return this;};
	this.parentNotNull=function(){if(this.proxy)return this.getProxy().parentNotNull();this.put("parentNot", "not");this.put("parent", null);return this;};
	this.parentNot=function(parent){if(this.proxy)return this.getProxy().parentNot(parent);this.put("parentNot", "not");this.put("parent", parent);return this;};
	this.parentIn=function(ids){
		if(this.proxy)return this.getProxy().parentIn(ids);  this.put("parentIn", ids);return this;
	};	
	
	/** 全称        **/
	this.fullName=function(fullName){if(this.proxy)return this.getProxy().fullName(fullName);  this.put("fullName", fullName);return this;};
	/** and full_name is null */
	this.fullNameNull=function(){if(this.proxy)return this.getProxy().fullNameNull();if(this.get("fullNameNot")==null)this.put("fullNameNot", "");this.put("fullName", null);return this;};
	/** not .... */
	this.fullNameNot=function(){if(this.proxy)return this.getProxy().fullNameNot();this.put("fullNameNot", "not");return this;};
	this.fullNameNotNull=function(){if(this.proxy)return this.getProxy().fullNameNotNull();this.put("fullNameNot", "not");this.put("fullName", null);return this;};
	this.fullNameNot=function(fullName){if(this.proxy)return this.getProxy().fullNameNot(fullName);this.put("fullNameNot", "not");this.put("fullName", fullName);return this;};
	
	/** 编码        **/
	this.code=function(code){if(this.proxy)return this.getProxy().code(code);  this.put("code", code);return this;};
	/** and code is null */
	this.codeNull=function(){if(this.proxy)return this.getProxy().codeNull();if(this.get("codeNot")==null)this.put("codeNot", "");this.put("code", null);return this;};
	/** not .... */
	this.codeNot=function(){if(this.proxy)return this.getProxy().codeNot();this.put("codeNot", "not");return this;};
	this.codeNotNull=function(){if(this.proxy)return this.getProxy().codeNotNull();this.put("codeNot", "not");this.put("code", null);return this;};
	this.codeNot=function(code){if(this.proxy)return this.getProxy().codeNot(code);this.put("codeNot", "not");this.put("code", code);return this;};
	/** and code <= ? */
	this.codeMin=function(min){if(this.proxy)return this.getProxy().codeMin(min);this.put("codeMin", min);return this;};
	/** and code >= ? */
	this.codeMax=function(max){if(this.proxy)return this.getProxy().codeMax(max);this.put("codeMax", max);return this;};
	this.codeIn=function(ids){
		if(this.proxy)return this.getProxy().codeIn(ids);  this.put("codeIn", ids);return this;
	};	
	
	/** 修改时间 [非空]       **/
	this.updateTime=function(updateTime){if(this.proxy)return this.getProxy().updateTime(updateTime);  this.put("updateTime", updateTime);return this;};
	/** and update_time is null */
	this.updateTimeNull=function(){if(this.proxy)return this.getProxy().updateTimeNull();if(this.get("updateTimeNot")==null)this.put("updateTimeNot", "");this.put("updateTime", null);return this;};
	/** not .... */
	this.updateTimeNot=function(){if(this.proxy)return this.getProxy().updateTimeNot();this.put("updateTimeNot", "not");return this;};
	this.updateTimeNotNull=function(){if(this.proxy)return this.getProxy().updateTimeNotNull();this.put("updateTimeNot", "not");this.put("updateTime", null);return this;};
	this.updateTimeNot=function(updateTime){if(this.proxy)return this.getProxy().updateTimeNot(updateTime);this.put("updateTimeNot", "not");this.put("updateTime", updateTime);return this;};
	/** and update_time >= ? */
	this.updateTimeStart=function(start){if(this.proxy)return this.getProxy().updateTimeStart(start);this.put("updateTimeStart", start);return this;};			
	/** and update_time <= ? */
	this.updateTimeEnd=function(end){if(this.proxy)return this.getProxy().updateTimeEnd(end);this.put("updateTimeEnd", end);return this;};
	
	/** 添加时间 [非空]       **/
	this.addTime=function(addTime){if(this.proxy)return this.getProxy().addTime(addTime);  this.put("addTime", addTime);return this;};
	/** and add_time is null */
	this.addTimeNull=function(){if(this.proxy)return this.getProxy().addTimeNull();if(this.get("addTimeNot")==null)this.put("addTimeNot", "");this.put("addTime", null);return this;};
	/** not .... */
	this.addTimeNot=function(){if(this.proxy)return this.getProxy().addTimeNot();this.put("addTimeNot", "not");return this;};
	this.addTimeNotNull=function(){if(this.proxy)return this.getProxy().addTimeNotNull();this.put("addTimeNot", "not");this.put("addTime", null);return this;};
	this.addTimeNot=function(addTime){if(this.proxy)return this.getProxy().addTimeNot(addTime);this.put("addTimeNot", "not");this.put("addTime", addTime);return this;};
	/** and add_time >= ? */
	this.addTimeStart=function(start){if(this.proxy)return this.getProxy().addTimeStart(start);this.put("addTimeStart", start);return this;};			
	/** and add_time <= ? */
	this.addTimeEnd=function(end){if(this.proxy)return this.getProxy().addTimeEnd(end);this.put("addTimeEnd", end);return this;};
	
	/** 状态 [非空]   1:正常 0:无效     **/
	this.status=function(status){if(this.proxy)return this.getProxy().status(status);  this.put("status", status);return this;};
	/** and status is null */
	this.statusNull=function(){if(this.proxy)return this.getProxy().statusNull();if(this.get("statusNot")==null)this.put("statusNot", "");this.put("status", null);return this;};
	/** not .... */
	this.statusNot=function(){if(this.proxy)return this.getProxy().statusNot();this.put("statusNot", "not");return this;};
	this.statusNotNull=function(){if(this.proxy)return this.getProxy().statusNotNull();this.put("statusNot", "not");this.put("status", null);return this;};
	this.statusNot=function(status){if(this.proxy)return this.getProxy().statusNot(status);this.put("statusNot", "not");this.put("status", status);return this;};
	this.statusIn=function(ids){
		if(this.proxy)return this.getProxy().statusIn(ids);  this.put("statusIn", ids);return this;
	};	
	
	
	
	this.add=function(key,value) {if(proxy)return proxy().add(key,value);this.put(key, value);return this;}
	this.desc=function(sql) {if(proxy)return proxy().desc(sql);this.put("desc", sql);return this;}
	this.asc=function(sql) {if(proxy)return proxy().asc(sql);this.put("asc", sql);return this;}
	this.definex=function(sql) {if(proxy)return proxy().definex(sql);this.put("definex", sql);return this;}
	
	/** 获取所有省市地区 **/
	this.list=function(size){
		this.data.size = size;
		var protocol = ux.ajax("/admin/setting/region.list.do",this.data);
		if(!protocol)return null;
		if(protocol.data && protocol.data.list)return protocol.data.list;
		return [];
	}
	/** 获取省市地区分页 **/
	this.page=function(page,size){
		this.data.size = size;
		this.data.page = page;
		var protocol = ux.ajax("/admin/setting/region.list.do",this.data);
		if(!protocol)return null;
		if(protocol.data)return data;
		return {list:[]};
	}
	/** 根据查询条件取省市地区 **/
	this.get=function(){
		this.data.size = 1;
		var protocol = ux.ajax("/admin/setting/region.list.do",this.data);
		if(!protocol)return null;
		if(protocol.data && protocol.data.list && protocol.data.list.length==1)return protocol.data.list[0]; 
		return null;
	}
}

Region.get = function(id){
	var protocol = ux.ajax("/admin/setting/region.get.do",{id:id});
	if(!protocol)return null;
	if(protocol.data)return protocol.data.region;
	return null;
}

Region.where = new Region.Where(0,true);